<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
/**
 * 公共函数文件
 */

 /**
 * 利用正则检测是否进行过md5加密
 * @param $string
 * @return mixed
 */
function is_md5($string) {
    return preg_match("/^[a-z0-9]{32}$/", $string);
}
/**
 * [checkfileexist description]
 * @param  [type] $url [description]
 * @return [type]      [description]
 */
function checkFileExist($url){
    trace("checkFileExist,url:$url");
    //1判断知否有值
    if(!$url){
        return false;
    }
    //2判断文件是否存在
    $basepath = $_SERVER['DOCUMENT_ROOT'];
    $filurl = str_replace('uploads/', 'public/uploads/', $url);
    $realurl = $basepath . $filurl;
    trace("checkFileExist,realurl:$realurl");        
    if(file_exists($realurl)){
        return true;
    }
    else{
        return false;
    }
}